# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: jaewon

from coin.exchange.bitmex.ws.subscriber import BitmexSubscriber
from coin.strategy.mm.feed_builder import BitmexFlowBookBuilder
from coin.strategy.mm.base.feed import BaseFeedSubsystem
from coin.strategy.mm.subscription import SubscriptionRequest


class BitmexFeedSubsystem(BaseFeedSubsystem):
  FeedSubReq = SubscriptionRequest('Futures', 'Bitmex', None)
  FeedSubscriber = BitmexSubscriber
  FlowBookBuilder = BitmexFlowBookBuilder

  def _get_subscription(self):
    sub_list = []
    for product in self._products:
      sub_list += [
          'orderBookL2:%s' % product.native_symbol,
          'trade:%s' % product.native_symbol,
          'instrument:%s' % product.native_symbol,
          'liquidation:%s' % product.native_symbol
      ]
    return ','.join(sub_list)
